package com.igeek.ssm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description SpringMVC配置类
 * @Author chenmin
 * @Version 1.0
 * @Date 2023/1/12 14:43
 *
 * 取代dispatcher-servlet.xml
 */
//开启WebMVC的功能
@EnableWebMvc
//配置扫描包，识别@Controller、@Service，将其注册至IOC容器中
@ComponentScan({"com.igeek.ssm.controller" , "com.igeek.ssm.service"})
public class SpringMVCConfig implements WebMvcConfigurer {

    //文件上传  多部件解析器
    @Bean
    public CommonsMultipartResolver multipartResolver(){
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        //当前多部件解析器，不仅可以支持POST请求、也可以支持PUT请求
        multipartResolver.setSupportedMethods("POST","PUT");
        multipartResolver.setMaxUploadSize(5242880);
        return multipartResolver;
    }

    //RestFul风格 对静态资源放行
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }


    //拦截器

    //全局异常处理器

    //本地图片服务器路径

    //转换器  String -->  Date

}
